import { IPageListParameter } from '../global'

/**
 * 用户相关
 */
export interface IAuthUser {
    id: number
    username: string
    avatar: string
    password: string
    state: 0 | 1
    create_time: string
    update_time: string

    _protect: 0 | 1
}

// 编辑
export type IAuthUserEditParameter = Omit<
    IAuthUser,
    'id' | 'create_time' | 'update_time' | '_protect'
> & {
    id?: IAuthUser['id']
}

// 删除
export interface IAuthUserDeleteParameter {
    id: IAuthUser['id']
}

// 登录
export interface IAuthUserLoginParameter {
    username: string
    password: string
    captcha: string
    remember: boolean
}

// 登录返回token
export type IAuthUserToken = {
    token: string
    expire: number
    refresh_token: string
    refresh_expire: number
}

// pinia
export type IAuthUserPinia = Omit<IAuthUser, 'id' | 'password' | '_protect'> & {
    id?: IAuthUser['id']
    isLoggedIn: boolean
}

// 账户设置
export interface IAuthUserSetInfoParameter {
    username: IAuthUser['username']
}

// 列表
export interface IAuthUserListParameter extends IPageListParameter {
    keyword?: string
    state?: IAuthUser['state']
    create_time?: string[]
}
